package com.atguigu.mapreduce.solution;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SolutionMapper1 extends Mapper<LongWritable, Text, Text, Text> {
    private final Text key = new Text();
    private final Text value = new Text();

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, Text>.Context context) throws IOException, InterruptedException {
        String[] splits = value.toString().split(":");

        this.value.set(splits[0]);
        for (String friend : splits[1].split(",")) {
            this.key.set(friend);
            context.write(this.key, this.value);
        }
    }
}
